﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Interop;
using System.Windows.Forms;
using Util;
using System.Diagnostics;
using System.Windows.Media.Animation;

namespace ISUM_V2
{

    /// <summary>
    /// 스크린 키보드
    /// </summary>
    public partial class ScreenKeyboard : Window
    {

        #region 멤버변수

        /// <summary>
        /// OnActivated 에서 사용하기 위한 객체
        /// </summary>
        //private WindowInteropHelper helper;
        
        /// <summary>
        /// Caps Lock 플래그(True = On)
        /// </summary>
        private bool Caps_flag;
        /// <summary>
        /// Shift 플래그(0 = Off, 1 = 1번, 2 = Forever)
        /// </summary>
        private int Shift_flag;
        /// <summary>
        /// 숫자 특수키 플래그(True = 숫자)
        /// </summary>
        private bool Number_flag;
        /// <summary>
        /// 주소 자동완성 화면 띄우는 플래그(True = On)
        /// </summary>
        private bool Address_flag;
        /// <summary>
        /// IME(한, 영)체크를 위한 핸들
        /// </summary>
        private IntPtr hWnd;
        /// <summary>
        /// IME(한, 영)체크를 위한 변수
        /// </summary>
        private IntPtr IME;
        /// <summary>
        /// IME(한, 영)체크 후 결과를 얻기위한 변수
        /// </summary>
        private IntPtr IMEResult;
        /// <summary>
        /// 한영 여부(1=한글, 0=영어)
        /// </summary>
        private int currentMode;
        /// <summary>
        /// 외부의 텍스트박스를 제어하기 위한 객체변수
        /// </summary>
        private System.Windows.Controls.TextBox tb;
        private System.Windows.Controls.UserControl uc;

        #endregion


        #region 생성자
        public ScreenKeyboard()
        {
            InitializeComponent();
        }
        public ScreenKeyboard(System.Windows.Controls.TextBox tb, System.Windows.Controls.UserControl uc)
        {
            InitializeComponent();
            Initialize(tb, uc);
            
        }

        #endregion


        #region 종료시 이벤트, 키보드 포커싱

        /// <summary>
        /// 키보드 종료시 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
         //   MainWindow.screen_flag = false;
        }

        /// <summary>
        /// 실제 가상키보드의 포커스 유지하기 위한 오버라이드 함수(사용하기 위해서는 helper의 주석과 아래 주석을 풀어야함)
        /// </summary>
        /// <param name="e"></param>
        protected override void OnActivated(EventArgs e)                //실제의 가상키보드처럼 쓰기위한 캐럿 포커스 유지
        {
            base.OnActivated(e);
            //  WinApi.SetWindowLong(this.helper.Handle, -20, WinApi.GetWindowLong(this.helper.Handle, -20) | 0x8000000);
        }

        #endregion

        
        #region 각종 초기화, 플래그 초기화


        /// <summary>
        /// 각종 초기화하기
        /// </summary>
        /// <param name="tb">제어할 TextBox 객체를 넘김</param>
        public void Initialize(System.Windows.Controls.TextBox tb, System.Windows.Controls.UserControl uc)
        {
            try
            {
                //helper = new WindowInteropHelper(this);
                InitFlag();
                this.tb = tb;
                this.uc = uc;
                
            }catch(Exception ex01)
            {
                Debug.WriteLine("Initialize Error - " + ex01.Message);
            }
        }

        /// <summary>
        /// 플래그 값 초기화하기
        /// </summary>
        private void InitFlag()
        {
            try
            {
                this.Caps_flag = WinApi.GetKeyState(WinApi.VirtualKeys.VK_CAPITAL) != 0;        //캡스락키 상태 받아오기(켜있으면 TRUE)
                this.Shift_flag = 0;
                this.Number_flag = false;
                this.Address_flag = false;
             //   MainWindow.screen_flag = true;

            }
            catch (Exception ex01)
            {
                Debug.WriteLine("InitFlag Error  - " + ex01.Message);
            }
        }

        #endregion


        #region IME체크, 키보드 싱글 이벤트, 키보드 쉬프트 이벤트

        /// <summary>
        /// IME 체크하기(1=한글)
        /// </summary>
        private void CheckIME()
        {
            // IME로 한글 판단
            try
            {
                this.hWnd = WinApi.GetForegroundWindow();
                this.IME = WinApi.ImmGetDefaultIMEWnd(this.hWnd);
                this.IMEResult = WinApi.SendMessage(this.IME, 0x283, 5, 0);
                WinApi.ImmReleaseContext(this.hWnd, this.IME);
                this.currentMode = this.IMEResult.ToInt32();
            }catch(Exception ex01)
            {
                Debug.WriteLine("CheckIME Error - " + ex01.Message);
            }
        }

       

        /// <summary>
        /// 키보드 일반 이벤트
        /// </summary>
        /// <param name="vk">키값 넘김</param>
        private void KeyEventSingle(WinApi.VirtualKeys vk)
        {
            try
            {
                CheckIME();
                tb.Focus();
                if (this.currentMode == 1)
                {
                    KeyEventHangleEng();
                }

                if (Shift_flag == 0)
                {
                    WinApi.keybd_event((byte)vk, 0, 0, 0);
                    WinApi.keybd_event((byte)vk, 0, 2, 0);

                }else if(Shift_flag >= 1 && Number_flag)
                {
                    WinApi.keybd_event((byte)vk, 0, 0, 0);
                    WinApi.keybd_event((byte)vk, 0, 2, 0);
                }
                else if (Shift_flag == 1 && !Number_flag)
                {
                    WinApi.keybd_event((byte)WinApi.VirtualKeys.VK_LSHIFT, 0, 0, 0);
                    WinApi.keybd_event((byte)vk, 0, 0, 0);
                    WinApi.keybd_event((byte)vk, 0, 2, 0);
                    WinApi.keybd_event((byte)WinApi.VirtualKeys.VK_LSHIFT, 0, 2, 0);

                    Shift_flag = 2;
                    ShiftChangeEvent();

                }
                else if (Shift_flag == 2 && !Number_flag)
                {
                    WinApi.keybd_event((byte)WinApi.VirtualKeys.VK_LSHIFT, 0, 0, 0);
                    WinApi.keybd_event((byte)vk, 0, 0, 0);
                    WinApi.keybd_event((byte)vk, 0, 2, 0);
                    WinApi.keybd_event((byte)WinApi.VirtualKeys.VK_LSHIFT, 0, 2, 0);
                }
            }catch(Exception ex01)
            {
                Debug.WriteLine("KeyEventSingle Error - " + ex01.Message);
            }
        }

        /// <summary>
        /// 키보드 쉬프트 이벤트
        /// </summary>
        /// <param name="vk">키값 넘김</param>
        private void KeyEventShift(WinApi.VirtualKeys vk)
        {
            try
            {
                
                WinApi.keybd_event((byte)WinApi.VirtualKeys.VK_LSHIFT, 0, 0, 0);
                KeyEventSingle(vk);
                WinApi.keybd_event((byte)WinApi.VirtualKeys.VK_LSHIFT, 0, 2, 0);
            }
            catch (Exception ex01)
            {
                Debug.WriteLine("KeyEventShift Error - " + ex01.Message);
            }
        }

        #endregion


        #region 키보드 쉬프트, 한영, 숫자 컨텍스트

        /// <summary>
        /// 키보드 쉬프트 누를때 컨텍스트 이벤트   
        /// </summary>
        private void ShiftChangeEvent()
        {
            try
            {
                if (Shift_flag == 0 && !Number_flag)
                {
                    Shift_flag = 1;
                    ChangeShiftImage("Image/button_128X256_shift_moment.png");

                }
                else if (Shift_flag == 1 && !Number_flag)
                {
                    Shift_flag = 2;
                    ChangeShiftImage("Image/button_128X256_shift_fixed.png");
                }
                else if (Shift_flag == 2 && !Number_flag)
                {
                    Shift_flag = 0;
                    ChangeShiftImage("Image/button_128X256_shift.png");
                }
            }
            catch (Exception ex01)
            {
                Debug.WriteLine("ShiftChangeEvent Error - " + ex01.Message);
            }
        }

        /// <summary>
        /// 쉬프트 누를때 이미지 변경하기
        /// </summary>
        /// <param name="path">이미지 경로</param>
        private void ChangeShiftImage(string path)
        {
            try
            {
                Image image = (Image)Btn_Shift.Template.FindName("image", Btn_Shift);
                ImageBrush imgBrush = new ImageBrush();
                imgBrush.ImageSource = new BitmapImage(new Uri(@"" + path, UriKind.Relative));
                imgBrush.Stretch = Stretch.Fill;
                image.Source = imgBrush.ImageSource;
            }
            catch (Exception ex01)
            {
                Debug.WriteLine("ChangeShiftImage Error - " + ex01.Message);
            }
        }


        /// <summary>
        /// 숫자와 알파벳 컨텍스트
        /// </summary>
        private void ChangeNumberKey()
        {
            try
            {
                if (Number_flag)
                {
                    Number_flag = false;
                    Btn_Number.Content = "__123";
                    ChangeNumberAlpabet(false);

                }
                else
                {
                    Shift_flag = 2;                 //쉬프트키 원상복구
                    ShiftChangeEvent();

                    Number_flag = true;
                    Btn_Number.Content = "ABC";
                    ChangeNumberAlpabet(true);

                }
            }
            catch (Exception ex01)
            {
                Debug.WriteLine("ChangeNumberKey Error - " + ex01.Message);
            }
        }

        /// <summary>
        /// 주소 자동완성 이미지 컨텍스트
        /// </summary>
        private void ChangeAddressImage()
        {
            try
            {
                Shift_flag = 2;

                ShiftChangeEvent();

                if (Address_flag)
                {
                    Address_flag = false;
                    Canvas_Main.Visibility = Visibility.Visible;
                    Canvas_Address.Visibility = Visibility.Hidden;
                }
                else
                {
                    Address_flag = true;
                    Canvas_Main.Visibility = Visibility.Hidden;
                    Canvas_Address.Visibility = Visibility.Visible;
                }
            }
            catch (Exception ex01)
            {
                Debug.WriteLine("ChangeAddressImage Error - " + ex01.Message);
            }
        }



        /// <summary>
        /// 숫자와 알파벳 키(Text) 컨텍스트
        /// </summary>
        /// <param name="flag">True = 숫자, False = 알파벳</param>
        private void ChangeNumberAlpabet(bool flag)
        {
            if (flag)
            {

                //첫번째 줄 변경하기
                Btn_Q.Content = "1";
                Btn_W.Content = "2";
                Btn_E.Content = "3";
                Btn_R.Content = "4";
                Btn_T.Content = "5";
                Btn_Y.Content = "6";
                Btn_U.Content = "7";
                Btn_I.Content = "8";
                Btn_O.Content = "9";
                Btn_P.Content = "0";

                //두번째 줄 변경하기
                Btn_A.Content = "_";
                Btn_S.Content = "-";
                Btn_D.Content = "/";
                Btn_F.Content = "\\";
                Btn_G.Content = ":";
                Btn_H.Content = ";";
                Btn_J.Content = "?";
                Btn_K.Content = "!";
                Btn_L.Content = "&";

                //세번째 줄 변경하기
                Btn_Z.Content = "#";
                Btn_X.Content = "$";
                Btn_C.Content = "%";
                Btn_V.Content = "^";
                Btn_B.Content = "=";
                Btn_N.Content = "*";
                Btn_M.Content = "+";
            }
            else
            {
                //원래대로 변경하기 (알파벳으로)
                //첫번째 줄 변경하기
                Btn_Q.Content = "Q";
                Btn_W.Content = "W";
                Btn_E.Content = "E";
                Btn_R.Content = "R";
                Btn_T.Content = "T";
                Btn_Y.Content = "Y";
                Btn_U.Content = "U";
                Btn_I.Content = "I";
                Btn_O.Content = "O";
                Btn_P.Content = "P";

                //두번째 줄 변경하기
                Btn_A.Content = "A";
                Btn_S.Content = "S";
                Btn_D.Content = "D";
                Btn_F.Content = "F";
                Btn_G.Content = "G";
                Btn_H.Content = "H";
                Btn_J.Content = "J";
                Btn_K.Content = "K";
                Btn_L.Content = "L";

                //세번째 줄 변경하기
                Btn_Z.Content = "Z";
                Btn_X.Content = "X";
                Btn_C.Content = "C";
                Btn_V.Content = "V";
                Btn_B.Content = "B";
                Btn_N.Content = "N";
                Btn_M.Content = "M";
            }
        }


        /// <summary>
        /// 키보드 한영 전환하기
        /// </summary>
        private static void KeyEventHangleEng()
        {
            try
            {
                WinApi.keybd_event((byte)WinApi.VirtualKeys.VK_HANGUL, 0, 0, 0);
                WinApi.keybd_event((byte)WinApi.VirtualKeys.VK_HANGUL, 0, 2, 0);
            }catch(Exception ex01)
            {
                Debug.WriteLine("KeyEventHangleEng Error - " + ex01.Message);
            }
        }

        #endregion


        #region 키보드 버튼 이벤트 모음

        private void Btn_Q_Click(object sender, RoutedEventArgs e)
        {
            Image image = (Image)Btn_Z.Template.FindName("image2222", Btn_Z);
            ImageBrush imgBrush = new ImageBrush();
            imgBrush.ImageSource = new BitmapImage(new Uri(@"" + "/ISUM_V2;component/Image/dashdot/_dashdash.PNG", UriKind.Relative));
            imgBrush.Stretch = Stretch.Fill;
            image.Source = imgBrush.ImageSource;
            
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_1);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_Q);
            }
        }

        private void Btn_W_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_2);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_W);
            }

        }

        private void Btn_E_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_3);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_E);
            }
        }

        private void Btn_R_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_4);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_R);
            }

        }

        private void Btn_T_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_5);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_T);
            }
        }
        private void Btn_Y_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_6);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_Y);
            }
        }

        private void Btn_U_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_7);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_U);
            }
        }

        private void Btn_I_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_8);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_I);
            }
        }

        private void Btn_O_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_9);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_O);
            }
        }

        private void Btn_P_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_0);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_P);
            }
        }

        private void Btn_A_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_OEM_MINUS);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_A);
            }
        }

        private void Btn_S_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_OEM_MINUS);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_S);
            }
        }

        private void Btn_D_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_OEM_2);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_D);
            }
        }

        private void Btn_F_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_OEM_5);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_F);
            }
        }

        private void Btn_G_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_OEM_1);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_G);
            }
        }

        private void Btn_H_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_OEM_1);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_H);
            }
        }

        private void Btn_J_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_OEM_2);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_J);
            }

        }

        private void Btn_K_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_1);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_K);
            }
        }

        private void Btn_L_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_7);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_L);
            }
        }

        private void Btn_Z_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_3);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_Z);
            }
        }

        private void Btn_X_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_4);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_X);
            }
        }

        private void Btn_C_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_5);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_C);
            }
        }

        private void Btn_V_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_6);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_V);
            }
        }

        private void Btn_B_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PLUS);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_B);
            }
        }

        private void Btn_N_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_8);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_N);
            }
        }

        private void Btn_M_Click(object sender, RoutedEventArgs e)
        {
            if (Number_flag)
            {
                KeyEventShift(WinApi.VirtualKeys.VK_OEM_PLUS);
            }
            else
            {
                KeyEventSingle(WinApi.VirtualKeys.VK_M);
            }
        }

        private void Btn_Shift_Click(object sender, RoutedEventArgs e)
        {
            ShiftChangeEvent();

        }
        private void Btn_Back_Click(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("back");
            KeyEventSingle(WinApi.VirtualKeys.VK_BACK);

        }

        private void Btn_Number_Click(object sender, RoutedEventArgs e)
        {
            ChangeNumberKey();
        }

        private void Btn_Address_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
        }


        private void Btn_At_Click(object sender, RoutedEventArgs e)
        {

            KeyEventShift(WinApi.VirtualKeys.VK_2);

        }

        private void Btn_Dot_Click(object sender, RoutedEventArgs e)
        {
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
        }

        private void Btn_DotCom_Click(object sender, RoutedEventArgs e)
        {
            Shift_flag = 2;                 //쉬프트키 원상복구
            ShiftChangeEvent();

            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);
        }

        private void Btn_DotNet_Click(object sender, RoutedEventArgs e)
        {
            Shift_flag = 2;                 //쉬프트키 원상복구
            ShiftChangeEvent();

            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_N);
            KeyEventSingle(WinApi.VirtualKeys.VK_E);
            KeyEventSingle(WinApi.VirtualKeys.VK_T);
        }

        private void Btn_Address_Naver_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_N);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_V);
            KeyEventSingle(WinApi.VirtualKeys.VK_E);
            KeyEventSingle(WinApi.VirtualKeys.VK_R);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        private void Btn_Address_Gmail_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_G);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_I);
            KeyEventSingle(WinApi.VirtualKeys.VK_L);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        private void Btn_Address_Nate_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_N);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_T);
            KeyEventSingle(WinApi.VirtualKeys.VK_E);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        private void Btn_Address_Yahoo_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_Y);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_H);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_K);
            KeyEventSingle(WinApi.VirtualKeys.VK_R);

        }

        private void Btn_Address_Paran_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_P);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_R);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_N);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        private void Btn_Address_Cyworld_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_Y);
            KeyEventSingle(WinApi.VirtualKeys.VK_W);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_R);
            KeyEventSingle(WinApi.VirtualKeys.VK_L);
            KeyEventSingle(WinApi.VirtualKeys.VK_D);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        private void Btn_Address_Hotmail_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_H);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_T);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_I);
            KeyEventSingle(WinApi.VirtualKeys.VK_L);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        private void Btn_Address_Dreamwiz_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_D);
            KeyEventSingle(WinApi.VirtualKeys.VK_R);
            KeyEventSingle(WinApi.VirtualKeys.VK_E);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);
            KeyEventSingle(WinApi.VirtualKeys.VK_W);
            KeyEventSingle(WinApi.VirtualKeys.VK_I);
            KeyEventSingle(WinApi.VirtualKeys.VK_Z);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_K);
            KeyEventSingle(WinApi.VirtualKeys.VK_R);

        }

        private void Btn_Address_Empas_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_E);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);
            KeyEventSingle(WinApi.VirtualKeys.VK_P);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_S);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        private void Btn_Address_Lycos_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_L);
            KeyEventSingle(WinApi.VirtualKeys.VK_Y);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_S);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_K);
            KeyEventSingle(WinApi.VirtualKeys.VK_R);

        }

        private void Btn_Address_Netsgo_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_N);
            KeyEventSingle(WinApi.VirtualKeys.VK_E);
            KeyEventSingle(WinApi.VirtualKeys.VK_T);
            KeyEventSingle(WinApi.VirtualKeys.VK_S);
            KeyEventSingle(WinApi.VirtualKeys.VK_G);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        private void Btn_Address_Empal_Click(object sender, RoutedEventArgs e)
        {
            ChangeAddressImage();
            KeyEventShift(WinApi.VirtualKeys.VK_2);
            KeyEventSingle(WinApi.VirtualKeys.VK_E);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);
            KeyEventSingle(WinApi.VirtualKeys.VK_P);
            KeyEventSingle(WinApi.VirtualKeys.VK_A);
            KeyEventSingle(WinApi.VirtualKeys.VK_L);
            KeyEventSingle(WinApi.VirtualKeys.VK_OEM_PERIOD);
            KeyEventSingle(WinApi.VirtualKeys.VK_C);
            KeyEventSingle(WinApi.VirtualKeys.VK_O);
            KeyEventSingle(WinApi.VirtualKeys.VK_M);

        }

        
        #endregion

     

    }
}
